package com.itheima.health.util;


import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;


/**
 * 日期工具类
 */
public class DateUtil {


    /**
     * 获取本月第一天
     * @return String
     **/
    public static LocalDate getMonthStart(LocalDate  nowDate) {

     return  nowDate.with(TemporalAdjusters.firstDayOfMonth());
    }

    /**
     * 获取本月最后一天
     * @return String
     **/
    public static LocalDate getMonthEnd(LocalDate nowDate) {

        //本月最后一天
       return nowDate.with(TemporalAdjusters.lastDayOfMonth());

    }

    /**
     * 获取本周的第一天
     * @return String
     **/
    public static LocalDate getWeekStart(LocalDate nowDate) {

        return nowDate.with(DayOfWeek.MONDAY);
    }

    /**
     * 本周最后一天
     * @return
     */
    public static LocalDate getWeekEnd(LocalDate nowDate) {

        return nowDate.with(DayOfWeek.SUNDAY);
    }
}
